
*******************************************************************************
*Author: Mimi Lyon
*Date: 1/10/2024
*Title: National Map of Strikes

*******************************************************************************

clear all
set more off
cd "/Users/ml212937/Dropbox (Brown)/Strikes Agenda Setting/Draft/Submissions/JHR/Final/Replication Files/"


*****************************State Level Strike Map **********************
*pull in state level data
use Data/statelvl_strikes, clear

use Data/state_coords_clean.dta, clear
    
    bysort _ID: egen x=median(_X)
    bysort _ID: egen y=median(_Y)
    
collapse (lastnm) x y,by(_ID)
    
    preserve
    
        use Data/state_database_clean.dta, clear
        
        keep statefips _polygonid
        
        rename _polygonid _ID
		
        save Data/state_id_fips, replace
        
    restore
    
merge 1:1 _ID using "Data/state_id_fips", update replace nogen    
	
	gen state = ""
	
    * state variable
    * al
    replace x=x+0.75 if statefips==1
    replace y=y+2 if statefips==1
	replace state = "AL" if statefips==1
	
    * ak
    replace x=x+0.5 if statefips==2
    replace y=y+3 if statefips==2
    replace state = "AK" if statefips==2

    * az
    replace x=x+2.5 if statefips==4
    replace y=y+0.5 if statefips==4
	replace state = "AZ" if statefips==4

    * ar
    replace x=x-0.75 if statefips==5
    replace y=y-0.5 if statefips==5
	replace state = "AR" if statefips==5

    * ca
    replace x=x+1.5 if statefips==6
    replace y=y+0.5 if statefips==6
	replace state = "CA" if statefips==6

    * co
    replace x=x-2.5 if statefips==8
	replace state = "CO" if statefips==8

    * ct
    replace x=x+0.15 if statefips==9
    replace y=y+0.55 if statefips==9
	replace state = "CT" if statefips==9

    * de TOO SMALL, out to sea!
    replace y=y-0.85 if statefips==10
    replace x=x+1.5 if statefips==10
	replace state = "DE" if statefips==10
    
    * dc TOO SMALL
    replace y=. if statefips==11
    replace x=. if statefips==11
	replace state = "DC" if statefips==11

    * fl
    replace x=x+0.75 if statefips==12
	replace state = "FL" if statefips==12

    * ga
    replace x=x-0.5 if statefips==13
    replace y=y+0.5 if statefips==13
	replace state = "GA" if statefips==13

    * hi
    replace x=x+3.5 if statefips==15
    replace y=y-1.75 if statefips==15
	replace state = "HI" if statefips==15

    * id
    replace y=y-2 if statefips==16
	replace state = "ID" if statefips==16
    
    * il is fine
	replace state = "IL" if statefips==17
    
    * in
    replace x=x+0.4 if statefips==18
    replace y=y+1.25 if statefips==18
	replace state = "IN" if statefips==18
    
    * ia is fine
	replace state = "IA" if statefips==19
    
    * ks
    replace x=x-0.5 if statefips==20
	replace state = "KS" if statefips==20
    
    * ky
    replace x=x+1 if statefips==21
    replace y=y-0.25 if statefips==21
	replace state = "KY" if statefips==21
    
    * la
    replace x=x-1.75 if statefips==22
    replace y=y+1.0 if statefips==22
	replace state = "LA" if statefips==22

    * me
    replace x=x-0.5 if statefips==23
    replace y=y+1.75 if statefips==23
	replace state = "ME" if statefips==23

    * md TOO SMALL out to sea
    replace x=x+2 if statefips==24
    replace y=y-1 if statefips==24
	replace state = "MD" if statefips==24

    * ma
    replace x=x+1.25 if statefips==25
    replace y=y+1 if statefips==25
	replace state = "MA" if statefips==25
    
    * mi
    replace x=x+1.5 if statefips==26
    replace y=y-4 if statefips==26
	replace state = "MI" if statefips==26

    * mn
    replace x=x-2 if statefips==27
    replace y=y-1 if statefips==27
	replace state = "MN" if statefips==27
    
    * ms
    replace x=x+0.5 if statefips==28
    replace y=y+1.5 if statefips==28
	replace state = "MS" if statefips==28
    
    * mo is fine
	replace state = "MO" if statefips==29
    
    * mt
    replace x=x+2.5 if statefips==30
	replace state = "MT" if statefips==30
    
    * ne
    replace x=x-0.5 if statefips==31
    replace y=y+0.75 if statefips==31
	replace state = "NE" if statefips==31

    * nv
    replace x=x-1.75 if statefips==32
    replace y=y+2.5 if statefips==32
	replace state = "NV" if statefips==32
    
    * nh
    replace x=x-0.35 if statefips==33
    replace y=y-0.35 if statefips==33
	replace state = "NH" if statefips==33
    
    * nj OUT TO SEA
    replace x=x+1.6 if statefips==34
    replace y=y-0.25 if statefips==34
	replace state = "NJ" if statefips==34

    * nm
    replace x=x-0.75 if statefips==35
    replace y=y+1.5 if statefips==35
	replace state = "NM" if statefips==35

    * ny
    replace x=x-1.25 if statefips==36
    replace y=y+2.25 if statefips==36
	replace state = "NY" if statefips==36
    
    * nc
    replace x=x-3 if statefips==37
	replace state = "NC" if statefips==37
    
    * nd
    replace x=x+0.85 if statefips==38
    replace y=y+1.35 if statefips==38
	replace state = "ND" if statefips==38
    
    * oh
    replace x=x-0.35 if statefips==39
    replace y=y-1.25 if statefips==39
	replace state = "OH" if statefips==39
    
    * ok
    replace y=y-1 if statefips==40
	replace state = "OK" if statefips==40
    
    * or
    replace x=x+2.5 if statefips==41
    replace y=y-1.5 if statefips==41
	replace state = "OR" if statefips==41
    
    * pa is fine
	replace state = "PA" if statefips==42
    
    * ri
    replace x=x+0.35 if statefips==44
    replace y=y-0.8 if statefips==44  
	replace state = "RI" if statefips==44
    
    * sc 
	replace y=y+0.4 if statefips==45 
	replace state = "SC" if statefips==45
    
    * sd
    replace x=x-0.75 if statefips==46
    replace y=y-0.5 if statefips==46
	replace state = "SD" if statefips==46

    * tn
    replace y=y-0.35 if statefips==47
	replace state = "TN" if statefips==47

    * tx
    replace x=x-1.25 if statefips==48
    replace y=y+2.75 if statefips==48
	replace state = "TX" if statefips==48

    * ut is fine
	replace state = "UT" if statefips==49
    
    * vt
    replace x=x-0.25 if statefips==50
    replace y=y+.5 if statefips==50
	replace state = "VT" if statefips==50

    * va
    replace x=x-1.5 if statefips==51
    replace y=y+0.25 if statefips==51
	replace state = "VA" if statefips==51
    
    * wa
    replace x=x+2 if statefips==53
    replace y=y-1.25 if statefips==53
	replace state = "WA" if statefips==53
    
    * wv
    replace x=x-0.25 if statefips==54
    replace y=y-0 if statefips==54
	replace state = "WV" if statefips==54
    
    * wi
    replace x=x-1.75 if statefips==55
    replace y=y-0.5 if statefips==55
	replace state = "WI" if statefips==55
    
    * wy
    replace x=x-1.5 if statefips==56
	replace state = "WY" if statefips==56
    
    keep x y state statefips
	
	merge m:1 state using Data/statelvl_strikes, nogen


 maptile diststrikes, geo(state) cutvalues(0(15)75) fcolor(gs15 yellow*.25 yellow gold orange orange_red red) twopt(legend(pos(5) title("District Strike Count", size(*0.75)) size(small)) legend(lab( 2 "0") lab(3 "1-15") lab(4 "16-30") lab(5 "31-45") lab(6 "46-60") lab(7 "61-75") lab(8 "76-90")) ) 
   *graph export "/Users/ml212937/Dropbox (Brown)/Strikes Agenda Setting/Stata/Graphs/LyonKraft-Figure-1.jpg", replace

maptile diststrikes, geo(state) cutvalues(0(15)75) fcolor(gs15 gs13 gs11 gs9 gs7 gs5 gs3) twopt(legend(pos(5) title("District Strike Count", size(*0.75)) size(small)) legend(lab( 2 "0") lab(3 "1-15") lab(4 "16-30") lab(5 "31-45") lab(6 "46-60") lab(7 "61-75") lab(8 "76-90")) ) 
   *graph export "/Users/ml212937/Dropbox (Brown)/Strikes Agenda Setting/Stata/Graphs/LyonKraft-Figure-1BW.jpg", replace
